home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
tsfaqp34.zip
/
FAQPAS4.TXT
< prev
next >
Wrap
Internet Message Format
|
1996-09-14
|
51KB
From ts@uwasa.fi Sat Sep 14 00:00:00 1996
Subject: FAQPAS4.TXT contents
Copyright (c) 1993-1996 by Timo Salmi
All rights reserved
FAQPAS4.TXT The fourth set of frequently (and not so frequently)
asked Turbo Pascal questions with Timo's answers. The items are in
no particular order.
You are free to quote brief passages from this file provided you
clearly indicate the source with a proper acknowledgment.
Comments and corrections are solicited. But if you wish to have
individual Turbo Pascal consultation, please post your questions to
a suitable Usenet newsgroup like news:comp.lang.pascal.borland. It
is much more efficient than asking me by email. I'd like to help,
but I am very pressed for time. I prefer to pick the questions I
answer from the Usenet news. Thus I can answer publicly at one go if
I happen to have an answer. Besides, newsgroups have a number of
readers who might know a better or an alternative answer. Don't be
discouraged, though, if you get a reply like this from me. I am
always glad to hear from fellow Turbo Pascal users.
....................................................................
Prof. Timo Salmi Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
ts@uwasa.fi http://uwasa.fi/~ts BBS 961-3170972; FIN-65101, Finland
--------------------------------------------------------------------
76) What are the current Pascal newsgroups on the Usenet news?
77) How do I detect the CapsLock status, how do I turn it on/off?
78) How do I detect if the F11 or F12 key has been pressed?
79) How do I extract (parse) substrings from an input string?
80) How do I find out the size of any kind of a file?
81) How do I format graphics output like in textmode writeln?
82) How do I detect if more than one standard key is pressed down?
83) How can I read a disk's Volume Serial Number?
84) How can I disable and then enable the keyboard in my TP program?
85) How do I get the character device name of the (first) CD-ROM?
86) How do I eject a CD-ROM using a Turbo Pascal program?
87) How do I find out if the ANSI.SYS driver has been loaded?
88) Where do I find Turbo Pascal tutorials and/or good textbooks?
89) How do I make an executable of my Turbo Pascal source program?
90) How can I quickly read the last byte of a file?
91) Is 2000 a leap year? What is the leap year algorithm?
92) Does anybody have a program that gives the week number?
93) How can I use OutText to write numbers in the graphics mode?
94) How can I redirect output to file if I use the Crt unit?
95) How to write a function to return true if I am in graphics mode?
96) My graph.tpu got corrupted. Someone please email me a new copy.
97) How can I avoid run-time errors in numeric input using readln?
98) How can I limit the user's readln input to e.g. 3 characters?
99) Can you tell a beginner how to delete files with Turbo Pascal?
100) Could you please explain shl and shr operators to a beginner?
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:16 1996
Subject: Usenet Pascal newsgroups
76. *****
Q: What are the current Pascal newsgroups on the Usenet news?
A: The following new Pascal newsgroups were created June 12, 1995
to replace the old comp.lang.pascal. The new Delphi newsgroups were
first created around July 10, 1995. Further Delphi newsgroups were
added in April 1996.
A special note about Delphi postings. Please use the delphi
newsgroups for the Delphi related postings. In particular, the
newsgroup comp.lang.pascal.borland is _NOT_ for Delphi related
subjects!
A second special note. Please avoid crossposting between the
newsgroups. In particular do not crosspost between the old and the
new newsgroups. It slows the transition to the new system. (This
automatic posting breaches the general non-crossposting tenet only
because it is relevant information about the arrangements of all the
newsgroups involved.)
CURRENT:
comp.lang.pascal.ansi-iso Pascal according to ANSI and ISO standards.
comp.lang.pascal.borland Borland's Pascal incl. Turbo Pascal (not Delphi!)
comp.lang.pascal.mac Macintosh based Pascals.
comp.lang.pascal.misc Pascal in general and ungrouped Pascals.
comp.lang.pascal.delphi.advocacy Contentious issues related to Delphi.
comp.lang.pascal.delphi.announce Delphi related announcements. (Moderated)
comp.lang.pascal.delphi.components.misc General component issues.
comp.lang.pascal.delphi.components.usage Using pre-written components.
comp.lang.pascal.delphi.components.writing Writing Delphi components.
comp.lang.pascal.delphi.databases Database aspects of Borland Delphi.
comp.lang.pascal.delphi.misc General issues with Borland Delphi.
comp.sources.delphi Delphi and ObjectPascal source code. (Moderated)
RELATED of potential interest:
comp.os.msdos.programmer.turbovision Borland's text application libraries
OLD: Please cease using!
comp.lang.pascal Discussion about Pascal.
comp.lang.pascal.delphi.components Writing components in Borland Delphi.
For more information about the Pascal newsgroups please see
52703 Jun 14 1995 ftp://garbo.uwasa.fi/pc/doc-net/pasgroup.zip
pasgroup.zip Information about the comp.lang.pascal.* newsgroups
If your site is not getting the new Pascal newsgroups, please
contact your own site's newsmaster about the situation.
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:17 1996
Subject: Capslock status and toggling
77. *****
Q: How do I detect the CapsLock status, how do I turn it on/off?
A: Here are the relevant Turbo Pascal routines in answer to these
questions.
{}
Uses Dos; { The Dos unit is needed }
{}
(* Is CapsLock on *)
function CAPSONFN : boolean;
var regs : registers;
KeyStatus : byte;
begin
FillChar (regs, SizeOf(regs), 0);
regs.ax := $0200; { Get shift flags }
Intr ($16, regs); { The keyboard interrupt }
KeyStatus := regs.al; { AL = shift status bits }
if (KeyStatus and $40) > 0 then { bit 6 }
capsonfn := true
else
capsonfn := false;
end; (* capsonfn *)
{}
(* Set CapsLock. Use true to turn on, false to turn off *)
procedure CAPS (TurnOn : boolean);
var keyboardStatus : byte absolute $0040:$0017;
regs : registers;
begin
if TurnOn then
keyboardStatus := keyboardStatus or $40
else
keyboardStatus := keyboardStatus and $BF;
{ Interrrupt "check for keystroke" to ensure the LED status }
FillChar (regs, SizeOf(regs), 0);
regs.ah := $01;
Intr ($16, regs);
end; (* caps *)
{}
As you see, CapsLock is indicated by bit 6. The other toggles can be
handled in an equivalent way using this information about the memory
location Mem[$0040:$0017]:
ScrollLock = bit 4 $10 $EF
NumLock = bit 5 $20 $DF
CapsLock = bit 6 $40 $BF
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:18 1996
Subject: Detecting F11 and F12
78. *****
Q: How do I detect if the F11 or F12 key has been pressed?
A: Here is a sample program
uses Dos;
(* Enhanced keyboard ReadKey, no Crt unit needed. Detects also F11
and F12, and distinguishes between the numeric keypad and the
gray keys. Lower part of the word returns the first scan code,
the higher part the second *)
function RDENKEFN : word;
var regs : registers;
keyboard : byte absolute $40:$96;
begin
rdenkefn := 0;
if ((keyboard shr 4) and 1) = 0 then exit;
FillChar (regs, SizeOf(regs), 0);
regs.ah := $10;
Intr ($16, regs);
rdenkefn := regs.ax;
end; (* rdenkefn *)
{}
procedure TEST;
var key : word;
begin
while Lo(key) <> 27 do { esc exits }
begin